function Rectangle(name, width, height) {
  this.name = name;
  this.width = width;
  this.height = height;
  this.area = function () {
  	return this.width * this.height;
  };
}


const rect = new Rectangle('Rect', 10, 10);

console.log(Object.getPrototypeOf(rect));
// 输出：{ constructor: [Function: Rectangle] }

console.log(rect);
// 输出：Rectangle { name: '矩形 1', width: 10, height: 10 }
console.log(Object.getPrototypeOf(rect));
// 输出：{ area: [Function: area], constructor: [Function: Rectangle] }

Rectangle.prototype.perimeter = function () {
  return 2 * (this.width + this.height);
  };
  Rectangle.prototype.isSquare = function () {
  return this.width === this.height;
  };
  Rectangle.prototype.changeName = function (newName) {
  this.name = newName;
  }

  console.log(rect.perimeter()); // 输出：40
  console.log(rect.isSquare()); // 输出：true
  rect.changeName("测试矩形");
  console.log(rect.name); // 输出：测试矩形

  const rect2 = new Rectangle("矩形 2", 30, 40);
console.log(rect2.area()); // 输出：1200
console.log(rect2.perimeter()); // 输出：140
console.log(rect2.isSquare()); // 输出：false

console.log(Object.getPrototypeOf(rect));
// 输出：{ area: [Function: area], perimeter: [Function: perimeter], isSquare: [Function: isSquare], changeName: [Function:changeName], constructor: [Function: Rectangle] }
